
// 详情页逻辑

// 0. 获取元素
const infoBox = document.querySelector('.info')
const detailBox = document.querySelector('.detail')
const goodsId = window.sessionStorage.getItem('goods_id')


// 2. 根据 goodsId 去请求商品详情
getGoodsInfo()
async function getGoodsInfo() {

  const res = await pAjax({
    url: 'http://localhost:8888/goods/item',
    data: `id=${goodsId}`,
    dataType: 'json',
  })


  // 渲染页面
  infoBox.innerHTML = `
  <div class="info container box" id="box">
    <div class="show left ">
      <img src="${ res.info.img_big_logo }" alt="">
      <div class="mask"></div>
    </div>
    <div class="right">
      <div class="desc">${ res.info.title }</div>
      <div class="price">￥ ${ res.info.current_price }</div>
      <button>加入购物车</button>
    </div>
   <div class="enlarge" style="background: url(${ res.info.img_big_logo });background-size: 1200px 1200px;"></div>
  </div>
  `

  detailBox.innerHTML = res.info.goods_introduce;

  
  const e = new Enlarge('#box')



}


